import {service} from '@/utils/http'

/* 获取一周内浏览数最高的blog */
export const listOrderByViewNum = () => {
    const url = `blogCenter/blogInfo/listOrderByViewNum`
    return service.get(url)
}

/* 点赞（未使用） */
export const addLikeNum = (id) => {
    const url = `blogCenter/blogInfo/likeNum?id=` + id
    return service.post(url, id)
}

/* 点赞 */
export const likeNum = (blogId, userId) => {
    const url = `blogCenter/blogInfo/likeNum?id=` + blogId + `&userId=` + userId
    return service.post(url, blogId, userId)
}

/* 保存博客，（未使用） */
export const saveBlogInfo = (params) => {
    const {blogInfoAndTagForm, typeId, userId} = params
    const url = `userCenter/user/saveBlogInfo?typeId=` + typeId + `&userId=` + userId;
    return service.post(url, blogInfoAndTagForm)
}

/* 保存博客 */
export const saveBlogInfoByTagNames = (params) => {
    const {blogInfoAndTagForm, typeId, userId} = params
    const url = `userCenter/user/saveBlogInfoByTagNames?typeId=` + typeId + `&userId=` + userId;
    return service.post(url, blogInfoAndTagForm)
}

/* 通过博客id查询对应的博客 */
export const findBlogInfoByBlogId = (blogId) => {
    const url = `blogCenter/blogInfo/findBlogInfoAndTagsByBlogInfoId/` + blogId
    return service.get(url, blogId)
}

/* 获取最近 N 条博客记录 */
export const findRecentlyTopNumberBlogInfo = (number) => {
    const url = `blogCenter/blogInfo/findRecentlyTopNumberBlogInfo?number=` + number
    return service.get(url, number)
}

/* 获取指定用户最近 N 条博客记录 */
export const findRecentlyTopNumberBlogInfoByUserId = (number, userId) => {
    const url = `blogCenter/blogInfo/findRecentlyTopNumberBlogInfoByUserId?number=` + number + `&userId=` + userId
    return service.get(url, number, userId)
}

/* 通过用户id查询指定访问量最高的前几条数据 */
export const findTopNumberPageViewByUserId = (number, userId) => {
    const url = `blogCenter/blogInfo/findTopNumberPageViewByUserId?number=` + number + `&userId=` + userId
    return service.get(url, number, userId)
}

/* 按照条件 查询所有博客 */
export const findAllBlogByFuzzy = (params) => {
    const url = `blogCenter/blogInfo/findAllBlogByFuzzy`
    return service.post(url, params)
}
